<?php
    function logResult($word='') {
        $fp = fopen("log.txt","a");
        flock($fp, LOCK_EX) ;
        fwrite($fp,"执行日期：".strftime("%Y%m%d%H%M%S",time())."\n".$word."\n");
        flock($fp, LOCK_UN);
        fclose($fp);
    }

    /**
	 * [returnApiSuccess 返回正确json信息]
	 * @param  [type] $msg  [description]
	 * @param  array  $data [description]
	 * @return [type]       [description]
	 */
	function returnApiSuccess($msg = null,$data){ 
		if(!$data) $data = "";
		 $result = array(    
		 	  'sig' => 0,  
		 	  'msg' => $msg,   
		 	  'res' => $data 
		  );  

		 die(json_encode($result));
	}  
	
	function returnArr($msg = null,$data = array()){ 
	
		 $result = array(    
		 	  'sig' => 0,  
		 	  'msg' => $msg,   
		 	  'res' => $data 
		  );  

		 die(json_encode($result));
	}  
	

	/**
	 * [returnApiSuccess 返回错误json信息]
	 * @param  [type] $msg  [description]
	 * @param  array  $data [description]
	 * @return [type]       [description]
	 */
	function returnApiError($sig = 1,$msg){
		if(!$msg) $msg = "";
		 $result = array(    
		 	  'sig' => $sig,  
		 	  'msg' => $msg,
		  );  

		// die(json_encode($result,JSON_UNESCAPED_UNICODE));
		 die(json_encode($result));
	}  

